﻿#define TRACE_IN
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProjectEulerSolutions.Problems
{
    /*
     * In the following equation x, y, and n are positive integers.
1

x
	+ 	
1

y
	= 	
1

n

For n = 4 there are exactly three distinct solutions:
1

5
	+ 	
1

20
	= 	
1

4
1

6
	+ 	
1

12
	= 	
1

4
1

8
	+ 	
1

8
	= 	
1

4

What is the least value of n for which the number of distinct solutions exceeds one-thousand?

NOTE: This problem is an easier version of problem 110; it is strongly advised that you solve this one first.

     * */
    class Problem108 : IProblem
    {
        public string Calculate()
        {
            long[] primes = new long[] { 2, 3, 5, 7, 11, 13, 6 };

            long n = 1;
            int count = 0;
            for (int j = 0; j < primes.Length && count < 1000; j++)
            {
                n *= primes[j];
                count = 0;
                for (long y = n + 1; y <= 2 * n; y++)
                {
                    if (n * y % (y - n) == 0)
                        count++;
                }
                Console.WriteLine(count);
            }

            return n.ToString();
        }
    }
}
